package com.hd.assistant.dal.dao.ibatis;


import com.hd.assistant.dal.dao.UserDao;
import com.hd.assistant.dal.dao.exception.DAOException;
import com.hd.assistant.dal.dataobject.User;
import com.taobao.common.dao.persistence.DBRoute;
import com.taobao.common.dao.persistence.SqlMapBaseDAO;


public class IbatisUserDao extends SqlMapBaseDAO implements UserDao {

	public User getUserByUserIdAndType(Long userId, String userType) throws DAOException {
		try{
			User u = new User();
			u.setUserId(userId);
			u.setUserType(userType);
			return (User)this.executeQueryForObject("User.selectUserDOByUserid", u,DBRoute.getAssistantRoute());
		}catch(Exception e){
			throw new DAOException("IbatisUserDao.getUserByUserIdAndType", e);
		}
	}

	public void insertUser(User user)throws DAOException {
		try{
		this.executeInsert("User.insertUserDO", user,DBRoute.getAssistantRoute());
	}catch(Exception e){
		throw new DAOException("IbatisUserDao.insertUser", e);
	}
	}

	public int updateUser(User user)throws DAOException {
		try{
			return this.executeUpdate("User.updateUserDO", user,DBRoute.getAssistantRoute());
		}catch(Exception e){
			throw new DAOException("IbatisUserDao.updateUser", e);
		}
	}
   
}
